#include <iostream>
#include <vector>
#include <unordered_map>
#include <algorithm>
using namespace std;
/**
 * @brief
 * 1 <= position.length <= 100
 * 1 <= position[i] <= 10^9
 *
 */
class Solution
{
public:
    int minCostToMoveChips(vector<int> &position)
    {
        int even = 0, odd = 0;
        for (int pos : position)
        {
            pos % 2 ? odd++ : even++;
        }
        return min(odd, even);
    }

    int minCostToMoveChips_2(vector<int> &position)
    {
        size_t num = count_if(position.begin(), position.end(), [](int i)
                              { return i & 1; });
        return min(num, position.size() - num);
    }
};
int main()
{
    Solution s;
    vector<int> position = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30};
    cout << s.minCostToMoveChips_2(position) << endl;
    system("pause");
    return 0;
}
